package at.jku.cp.mir;

import java.io.File;
import java.io.FileNotFoundException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;

import at.jku.cp.mir.data.ArtistTopTagsFetcher;
import at.jku.cp.mir.data.ArtistTopTrackTagsFetcher;

public class DataCollector
{

	public static void main(String[] args) throws URISyntaxException
	{
		URL artistsURL = DataCollector.class.getResource("C224a_with_lastfm_artist_names.txt");
		URI uri = artistsURL.toURI();
		File artistsFile = new File(uri);

		File artistTopTagsDir = new File("artistTopTags");
		artistTopTagsDir.mkdirs();

		File topTrackTagsDir = new File("topTrackTags");
		topTrackTagsDir.mkdirs();

		DataCollector dataCollector = new DataCollector();
		dataCollector.collectData(artistsFile, artistTopTagsDir, topTrackTagsDir);
	}

	public DataCollector()
	{
		super();
	}

	public void collectData(File artistsFile, File artistTopTagsDir, File topTrackTagsDir)
	{
		ArtistTopTagsFetcher artistTopTagsFetcher = new ArtistTopTagsFetcher(artistsFile, artistTopTagsDir);
		try
		{
			artistTopTagsFetcher.fetchData();
		} catch (FileNotFoundException e)
		{
			e.printStackTrace();
			System.out.println("exception while getting artist top tags");
		}

		ArtistTopTrackTagsFetcher artistTopTrackTagsFetcher = new ArtistTopTrackTagsFetcher(artistsFile,
				topTrackTagsDir);
		try
		{
			artistTopTrackTagsFetcher.fetchData();
		} catch (FileNotFoundException e)
		{
			e.printStackTrace();
			System.out.println("exception while getting top track tags");
		}
	}

}
